#include "MessageProxyImpl.h"

#include <iostream>
#include <string>
#include <chrono>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include <thread>
#include <atomic>
#include <functional>
#include <string_view>
//#include <libwebsockets.h>
#include <fstream>

using namespace std::string_view_literals;

static bool gs_requestStop = false;
static void sigHnd(int)
{
	gs_requestStop = true;
}

int main(int argc, const char **argv)
{
    const char *p = nullptr;
	bool bSupportDeflate = false;

    signal(SIGINT, sigHnd);
    auto server = std::make_shared<sdk::message::proxy::MessageProxyImpl>(7681, bSupportDeflate);
    if (server == NULL)
    {
		std::cout << "testWebsocket::reason::create lws_server instance is failed" << std::endl;
        return -1;
    }
	
    try
    {
        int loop = 10000;
        while (loop-- && !gs_requestStop)
        {
            server->run();
        }
    }
    catch (const std::exception &e)
    {
        std::cerr << e.what() << '\n';
        return 1;
    }
	
    return 0;
}
